SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_cantidadfaltasporlocalidad
AS
SELECT     TOP 100 PERCENT l.localidad, m.menorde35, e.entre35y50, m5.mayorde50
FROM         dbo.tb_Localidades l LEFT OUTER JOIN
                      dbo.menor35 m ON l.localidad = m.localidad LEFT OUTER JOIN
                      dbo.entre35y50 e ON l.localidad = e.localidad LEFT OUTER JOIN
                      dbo.mayor50 m5 ON l.localidad = m5.localidad
WHERE     (m.menorde35 IS NOT NULL) OR
                      (e.entre35y50 IS NOT NULL) OR
                      (m5.mayorde50 IS NOT NULL)
ORDER BY m.menorde35, e.entre35y50, m5.mayorde50
GO
